package com.iwhalecloud.citybrain.flow.platform.manager.application.common.properties;

import com.iwhalecloud.citybrain.flow.platform.manager.application.common.enums.UserEnum;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

@Component
public class UserEnumProperties {

    @Value("${role.super:SUPER}")
    private String superCode;

    @PostConstruct
    public void getCode(){
        UserEnum.SUPER.setType(superCode);
        Map<String, UserEnum> typeToEnum = Arrays.stream(UserEnum.values()).collect(Collectors.toMap(UserEnum::type, item -> item));
        UserEnum.setTypeToEnum(typeToEnum);
    }
}
